// pages/mine/assemble/anotherDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    /**
     * 产品参数     */
    parameterList: [
      {
        title: "品牌",
        info: "贝智康"
      },
      {
        title: "品类",
        info: "婴配粉"
      },
      {
        title: "规格",
        info: "900克"
      },
      {
        title: "保质期 ",
        info: "720天"
      }
    ],
    /**
     * 选择产品规格显示
     */
    isShopSelect: false,
    /**
     * 产品规格列表
     */
    productSpecification: [
      {
        id: 1,
        title: "产品规格",
        list: [
          {
            id: 1,
            name: "1罐装",
            isChecked: true,
          },
          {
            id: 2,
            name: "2罐装",
            isChecked: false,
          },
          {
            id: 3,
            name: "3罐装",
            isChecked: false,
          },
          {
            id: 4,
            name: "4罐装",
            isChecked: false,
          },
          {
            id: 5,
            name: "5罐装",
            isChecked: false,
          }
        ]
      },
      {
        id: 2,
        title: "产品规格",
        list: [
          {
            id: 1,
            name: "1罐装",
            isChecked: true,
          },
          {
            id: 2,
            name: "2罐装",
            isChecked: false,
          },
          {
            id: 3,
            name: "3罐装",
            isChecked: false,
          },
          {
            id: 4,
            name: "4罐装",
            isChecked: false,
          },
          {
            id: 5,
            name: "5罐装",
            isChecked: false,
          }
        ]
      }
    ],
  },
  /**
   * 开团
   */
  shopSelect: function (e) {
    console.log(e);
    this.setData({
      isShopSelect: !this.data.isShopSelect,
    })
  },
  /**
   * 选择产品规格
   */
  specificationChecked: function (e) {
    let that = this;
    let father = e.currentTarget.dataset.father;//父级id
    let id = e.currentTarget.dataset.id;//自己的id
    let productSpecification = that.data.productSpecification;
    productSpecification.forEach(item => {
      if (item.id == father) {
        item.list.forEach(list => {
          if (list.id == id) {
            list.isChecked = !list.isChecked;
          }
          else {
            list.isChecked = false;
          }
        });
      }
    });
    that.setData({
      productSpecification: productSpecification
    })
  },
  /**
   * 确定
   */
  confirmBuy:function(){
    this.setData({
      isShopSelect: false,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})